package com.wallpaper;

import com.wallpaper.WallpaperActivity.MyAdapter;

import android.util.Log;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.widget.Gallery;
import android.widget.ImageView;

public class SimpleGestureDetector extends SimpleOnGestureListener {

	private Gallery gallery;

	public SimpleGestureDetector(Gallery gallery) {
		this.gallery = gallery;
	}

	private ImageView view;

	public ImageView getView() {
		return view;
	}

	public void setView(ImageView view) {
		this.view = view;
	}

	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
			float velocityY) {
		boolean result = super.onFling(e1, e2, velocityX, velocityY);
		if (!result) {
			view.setImageResource(MyAdapter.myImageIds[gallery
					.getSelectedItemPosition()]);
			Log.d("Fling " + System.currentTimeMillis(), e1.toString() + "\n"
					+ e2.toString());
		}

		return result;
	}
}
